package tests;

import junit.framework.*;
import Model.SingleTask;
import java.text.*;
import org.junit.Before;
import org.junit.Test;


/**
 * JUnit test case for SingleTaskTest
 */

public class SingleTaskTest extends TestCase {
	//declare reusable objects to be used across multiple tests
	private SingleTask t1;
	private SingleTask t2;
	java.sql.Date sqlDate;
	
	public SingleTaskTest(String name) {
		super(name);
	}

	//define reusable objects to be used across multiple tests
	
	@Before
    protected void setUp() {
    	DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    	
    	try { 
    	java.util.Date utilDate = new java.util.Date();
    	utilDate = df.parse("15/11/2011");
    	sqlDate = new java.sql.Date(utilDate.getTime());
    	 	
		t1 = new SingleTask(null, null,null);
		t2 = new SingleTask("Task 2", sqlDate,"Type 2");

		} 
		
		catch (ParseException e) {
			e.printStackTrace();
		}

    }
    
    @Test
    //Test SingleTaskConstructor
	public void testSingleTaskConstructor(){
				
		assertEquals(t2.getName(),"Task 2");
		assertEquals(t2.getDueDate(),sqlDate);
		assertEquals(t2.getType(),"Type 2");
		

	}
	
	//Test SingleTaskConstructor2
    @Test
	public void testSingleTaskConstructor2() {
    	
		t1 = new SingleTask(t2);
				
		assertEquals(t1.toString(),t2.toString());
		assertEquals(t1.getName(),t2.getName());
		assertEquals(t1.getDueDate(),t2.getDueDate());
		assertEquals(t1.getType(),t2.getType());

	}
	

}